﻿


<div ms-controller="tempview">
    <!--<div class="sui-form form-inline">
        <a class="sui-btn btn-large btn-primary" style="margin-left:10px;" ms-click="GetLIST()">刷新楼层</a>
        <a style="margin-left:10px;" class="sui-btn btn-large btn-success" ms-click="ADDLAYC('')">添加楼层</a>
    </div>-->
    <div class="sui-layout">
        <div class="sidebar">
            <p style="border-bottom: 2px solid #28a3ef;padding-bottom:10px;margin-top:0">所有楼层</p>
            <ul id="treeDemo" class="ztree"></ul>
        </div>
        <div class="content">

            <p style="border-bottom: 2px solid #28a3ef;padding-bottom:10px;">通道数据</p>
            <div id="chat" style="width:100%;height:200px;"></div>
            <div id="chat1" style="width:100%;height:200px;"></div>
            <div class="grid-demo">
                <div class="sui-row-fluid">
                    <div class="span3"></div>
                    <div class="span3"></div>
                    <div class="span3">2</div>
                    <div class="span3">2</div>
                </div>
                <div class="sui-row-fluid">
                    <div class="span2">2</div>
                    <div class="span2">2</div>
                    <div class="span2">2</div>
                    <div class="span2">2</div>
                </div>
            </div>


        </div>
    </div>
</div>
<script type="text/javascript">

       
    var myChart = echarts.init(document.getElementById('chat'), "macarons");
    var myChart1 = echarts.init(document.getElementById('chat1'), "macarons");

        function randomData() {
            now = new Date(+now + oneDay);
            value = value + Math.random() * 21 - 10;
            return {
                name: now.toString(),
                value: [
                    [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'),
                    Math.round(value)
                ]
            }
        }

        var data = [];
        var now = +new Date(1997, 9, 3);
        var oneDay = 24 * 3600 * 1000;
        var value = Math.random() * 1000;
        for (var i = 0; i < 1000; i++) {
            data.push(randomData());
        }

        option = {
            title: {
                text: 'CPU使用率'
            },
            legend: {
                data: ['最高气温']
            },
            tooltip: {
                trigger: 'axis',
                formatter: function (params) {
                    params = params[0];
                    var date = new Date(params.name);
                    return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' : ' + params.value[1];
                },
                axisPointer: {
                    animation: false
                }
            },
            xAxis: {
                type: 'time',
                splitLine: {
                    show: false
                }
            },
            yAxis: {
                type: 'value',
                boundaryGap: [0, '100%'],
                splitLine: {
                    show: false
                }
            },
            series: [{
                name: '模拟数据',
                type: 'line',
                showSymbol: false,
                hoverAnimation: false,
                data: data
            }]
        };
        myChart.setOption(option);
        myChart1.setOption(option);

        setInterval(function () {

            for (var i = 0; i < 5; i++) {
                data.shift();
                data.push(randomData());
            }

            myChart.setOption({
                series: [{
                    data: data
                }]
            });
            myChart1.setOption({
                title: {
                    text: '内存使用率'
                },
                series: [{
                    data: data
                }]
            });
        }, 1000);

   



    var treeObj;
    var tempmodel = avalon.define({
        $id: "tempview",
        search: { key: "" },
        page: { pageindex: 1, pagecount: 15 },
        modelData: {},
        modelData2: {},
        ShowColumns: [],
        ListData: [],
        PathList:[],
        ListData2:[],
        APINAME: "",
        Operation: "",
        IsLayc: true,
        LYID: "",
        PID:"",
        GetLIST: function () {

            ComFunJS.getJSON("BASE_GETLAYCTREE", function (r) {
                if (r.error == "") {
                    tempmodel.ListData = r.result;

                    var setting = {
                        callback: {
                            onClick: zTreeOnClick
                        }
                    };
                    var zNodes = eval("(" + JSON.stringify(r.result) + ")");

                    treeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);

                }
            })
        },
        GetEqu: function (ID) {
            if (ID) {
                tempmodel.PID = ID;
            }
            tempmodel.ListData2.clear();
            ComFunJS.getJSON("BASE_GETPATHDATALIST", { P1: tempmodel.LYID, P2: tempmodel.PID, pageindex: tempmodel.page.pageindex, pagecount: tempmodel.page.pagecount }, function (r) {
                if (r.error == "") {
                    tempmodel.ListData2 = r.result;

                    $("#pageDiv").pagination({  //分页容器
                        styleClass: ['sui-pagination'],  //分页样式
                        //showCtrl: false,
                        displayPage: 6,
                        itemsCount: r.total,
                        pageSize: tempmodel.page.pagecount,
                        onSelect: function (num) {
                            tempmodel.page.pageindex = num;
                            ComFunJS.getJSON("BASE_GETPATHDATALIST", { P1: tempmodel.LYID, P2: tempmodel.PID, pageindex: tempmodel.page.pageindex, pagecount: tempmodel.page.pagecount }, function (r) {
                                tempmodel.ListData2.clear();
                                tempmodel.ListData2 = r.result;
                            })
                        }
                    })

                    $('#pageDiv').pagination('updateItemsCount', r.total, 1);
                }

            })
        },
        GetPath: function () {
            tempmodel.PathList.clear();
            tempmodel.ListData2.clear();
            ComFunJS.getJSON("BASE_GETPATHLIST", { P1: tempmodel.LYID }, function (r) {
                if (r.error == "") {
                    tempmodel.PathList = r.result;
                    if (r.result && r.result.length>0) {
                        tempmodel.GetEqu(r.result[0].ID);
                    }
                }
            });
            
        }
    })
    avalon.ready(function () {
        //tempmodel.GetPath();
        tempmodel.GetLIST();
        //$(".sidebar").height(window.outerHeight - 100);
    })

    function zTreeOnClick(event, treeId, treeNode) {
        if (treeNode.lvl == "1") {
            //tempmodel.LYID = treeNode.ID;
            //tempmodel.PID = "";

        } else if(treeNode.lvl=="2") {
            tempmodel.LYID = treeNode.ID;
        }
        tempmodel.GetPath();
        //tempmodel.GetEqu();
        //tempmodel.GetEqu(treeNode.ID, treeNode.lvl);

    };

    //# sourceURL=pathd.js
</script>
